from django.db import models
from main.models import Book, Category, Author
from user.models import CustomUser


# Create your models here.
class BookShelf(models.Model):
    book = models.ForeignKey(verbose_name='收藏书名', to=Book, on_delete=models.CASCADE)
    category = models.ForeignKey(verbose_name='收藏书类别', to=Category, on_delete=models.CASCADE)
    author = models.ForeignKey(verbose_name='收藏书作者', to=Author, on_delete=models.CASCADE)
    user = models.ForeignKey(verbose_name='用户', to=CustomUser, on_delete=models.CASCADE)
    time = models.DateTimeField(verbose_name='收藏时间', auto_now_add=True)

    def __str__(self):
        return self.book.title

    class Meta:
        verbose_name = "书架"
        verbose_name_plural = "书架"